<?php $this->load->view('layout/header');?>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <h3 class="page-title">旅游商品<small> 议价</small></h3>
            <?php echo breadcrumb(array('tourismgoods/grid'=>'旅游商品','tourismgoodsbargaining/grid?goods_attr_id='.$this->input->get('goods_attr_id')=>'议价')); ?>
        </div>
    </div>
    <div class="alert alert-error" style="display:none;">
        <button data-dismiss="alert" class="close"></button>
        <a href="javascript:;" class="glyphicons no-js remove_2"><i></i><p></p></a>
    </div>
    <div class="row-fluid">
        <div class="span12">
            <div class="portlet box green">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-plus-sign"></i>议价</div>
                    <div class="tools">
                        <a class="collapse" href="javascript:;"></a>
                        <a class="remove" href="javascript:;"></a>
                    </div>
                </div>
                <div class="portlet-body form">
                    <form class="form-horizontal form-tourismgoodsbargaining" action="<?php echo base_url('tourismgoodsbargaining/addPost') ?>" method="post">
                    <input type="hidden" name="goods_attr_id" value="<?php echo $this->input->get('goods_attr_id');?>">
                    <input type="hidden" name="bargaining_id" value="<?php echo $this->input->get('bargaining_id');?>">
                    <input type="hidden" name="status" value="2">
                        <div class="control-group">
                            <label class="control-label"><em>* </em>分销商</label>
                            <div class="controls">
                                <input type="text" class="span6 medium required" name="user_name" >
                                <span class="help-inline">可以填写多个账户（如，test_fx01,test_fx）用，号隔开</span>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label"><em>* </em>供应商用户uid</label>
                            <div class="controls">
                                <input type="text" readonly value="<?php echo $info->uid;?>" name="provider_uid" class="m-wrap medium supplieruid required tooltips number" data-original-title="双击可弹框选择供应商；直接输入‘用户名称或编号’可提示" data-trigger="hover">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label"><em>* </em>销售价</label>
                            <div class="controls">
                                <input type="text" class="m-wrap medium required number" name="shop_price" >
                            </div>
                        </div>
                        <div class="control-group ">
                            <label class="control-label"><em>* </em> 结算价</label>
                            <div class="controls">
                                <input type="text" name="supply_price" class="m-wrap medium required number" >
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label"><em>* </em>总手续费</label>
                            <div class="controls">
                                <input type="text" name="poundage" class="m-wrap medium required number" >
                            </div>
                        </div>
                        <div class="control-group add-supplieruid-html">
                            <label class="control-label">二级供应商ID</label>
                            <div class="controls">
								<input type="text" name="prosecond_id"  class="m-wrap medium supplieruid  tooltips number " data-original-title="双击可弹框选择供应商；直接输入‘用户名称或编号’可提示" data-trigger="hover">
                            </div>
                        </div>
                        <div class="control-group ">
                            <label class="control-label">二级供应商利润</label>
                            <div class="controls">
                                <input type="text" class="m-wrap medium number" name="prosecond_profit" value="0">
                            </div>
                        </div>
                        <div class="control-group ">
                            <label class="control-label">银行手续费</label>
                            <div class="controls">
								<input type="text" name="bankpay"  class="m-wrap medium number" >
                            </div>
                        </div>
                        <div class="control-group ">
                           <label class="control-label"><em>* </em>结算方式</label>
						   <div class="controls">
                                <label class="radio">
                                    <input type="radio" checked="checked" name="node" value="1">系统结算
                                </label>
                                <label class="radio">
                                    <input type="radio" name="node" value="2">自主结算
                                </label> 
                            </div>
                        </div>
                         <div class="control-group">
                            <label class="control-label"><em>* </em>手续费支付方式</label>
                            <div class="controls">
                                <label class="radio">
                                    <input type="radio" checked="checked" name="payer" value="1">购买者
                                </label>
                                <label class="radio">
                                    <input type="radio"  name="payer" value="2">供应商
                                </label>
                                <label class="radio">
                                    <input type="radio"  name="payer" value="3">二级供应商
                                </label>
                            </div>
                        </div>
                        <div class="row-fluid margin-bottom-40 add-supplieruid-html">
                            <div class="span8  pricing pricing-active hover-effect">
                                <div class="pricing-head pricing-head-active">
                                    <h3>商品议价分润</h3>
                                </div>
                                <ul class="pricing-content unstyled">
                                    
                                 </ul>
                                <div class="pricing-footer">
                                     <p style="font-size: 16px;color:red;"></p>
                                     <a id="profit_add" class="btn green " href="javascript:void(0);">添加分润人者<i class="m-icon-swapright m-icon-white "></i></a> 
                                </div>
                            </div>
                        </div>
                        <div class="form-actions">
                            <button class="btn green" type="submit"><i class="icon-ok"></i> 保存</button>
                            <a href="<?php echo base_url('tourismgoodsbargaining/grid?goods_attr_id='.$this->input->get('goods_attr_id')) ?>">
                                <button class="btn" type="button">返回</button>
                            </a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $("#profit_add").click(function(){
    	var _val = '<li><i class="icon-tags"></i> <select name="type_id[]" class="m-wrap small"><option value="16" >着想总部</option><option value="64" >一级代理商</option><option value="256" >二级代理商</option><option value="4096" >分销商</option></select> <input class="m-wrap small number supplieruid" type="text" name="uid[]" value="0"> 利润 <input class="m-wrap small number" type="text" name="amount[]" value="0"> <a href="javascript:void(0);" class="btn mini profit_delete">删除</a></li>';
        $(this).parent('.pricing-footer').prev().append(_val);
    });
    $('ul.pricing-content').on('click', ".profit_delete", function(){
        $(this).parent('li').remove();
    });
    $('.form-tourismgoodsbargaining').submit(function(){
        return false;
    }).validate({
        submitHandler: function(f) {
            $.ajax({
                type: 'post',
                async: true,
                dataType : 'json',
                url: hostUrl()+'/tourismgoodsbargaining/ajaxValidate',
                data: $('.form-tourismgoodsbargaining').serialize(),
                success: function(data) {
                    if (data.status) {
                        $('.alert-error').hide();
                        window.location.href = data.msg;
                     } else {
                         $('.alert-error').show();
                         $('.remove_2 p').html(data.msg);
                         var body = (window.opera) ? (document.compatMode == 'CSS1Compat' ? $('html') : $('body')) : $('html,body');
                         body.animate({scrollTop: $('.page-container').offset().top}, 1000);
                         return false;
                     }
                }
            });
        }
    });
</script>
<?php $this->load->view('layout/footer');?>
<?php $this->load->view('user/addSupplierUid/ajaxGetUser');?>